package com.example.demo.设计模式.代理模式.JDK代理;

import java.lang.reflect.Proxy;

public class Test {
    public static void main(String[] args) {
        RealSubject realSubject = new RealSubject();
        ProxyHandler proxyHandler = new ProxyHandler();
        proxyHandler.setTarget(realSubject);

        Subject proxyObject = (Subject) Proxy.newProxyInstance(
                realSubject.getClass().getClassLoader(),
                realSubject.getClass().getInterfaces(),
                proxyHandler);

        proxyObject.doSomething();
    }
}
